<?xml version="1.0" encoding="ISO-8859-1"?>

<xsl:stylesheet version="1.0"
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
	xmlns:utils="xalan://hasthi.tools.XsltUtils"
	xmlns:fn="http://www.w3.org/2005/02/xpath-functions"
	xmlns:hmns="http://extreme.indiana.edu/manager/">
	<xsl:template match="/hmns:ManagerContext">
		<html>
			<head>
				<title>Hasthi Status Page</title>
				<meta http-equiv="refresh" content="30" />
			</head>
			<body>
				<h2>Management System State</h2>
				<table border="1">
					<tr>
						<td>Coordinator</td>
						<td>
							<a>
								<xsl:variable name="coordinator"
									select="hmns:ManagementRing/hmns:coordinator">
								</xsl:variable>
								<xsl:attribute name="href">
    								<xsl:value-of select="concat(normalize-space(hmns:ManagementRing/hmns:coordinator/hmns:soapAddress),'/hasthi/allresources')" />
    							</xsl:attribute>
								<xsl:value-of select="hmns:ManagementRing/hmns:coordinator/hmns:soapAddress" />
								(<xsl:value-of select="hmns:ManagementRing/hmns:coordinator/hmns:rank" />)
							</a>
						</td>
					</tr>
					<tr>
						<td>Manager Count</td>
						<td>
							<xsl:value-of
								select="count(hmns:ManagementRing/hmns:ManagerData)" />
						</td>
					</tr>
					<tr>
						<td>Resource Count</td>
						<td>
							<xsl:value-of
								select="count(//hmns:resourceData)" />
						</td>
					</tr>
					<tr>
						<td>Control Loop Active</td>
						<td>
							<xsl:value-of
								select="//hmns:activeManagement" />
						</td>
					</tr>
					<tr>
						<td>System Health Status</td>
						<td>
							<xsl:value-of
								select="//hmns:systemHealth" />
						</td>
					</tr>
					
				</table>
				<h2>Management Data</h2>
				<table border="1">
					<xsl:for-each
						select="hmns:ManagementRing/hmns:ManagerData">
						<xsl:variable name="managerAddress" select="hmns:managerAddress/hmns:soapAddress"></xsl:variable>
						
						<tr>
							<td>
								<a>
									<xsl:attribute name="href">
	    								<xsl:value-of
										select="concat(normalize-space($managerAddress),'/hasthi/resources')" />
	    							</xsl:attribute>
									<xsl:value-of
										select="$managerAddress" />
								</a>
							</td>
							<td>
								<table border="1">
								<xsl:for-each
									select="hmns:resourceData">
									<tr><td>
									<a><xsl:attribute name="href"><xsl:value-of
										select="concat(normalize-space($managerAddress),utils:resUrl(@name))" />
	    							</xsl:attribute><xsl:value-of select="@name"/></a>
									</td>
									<td><xsl:value-of select="@state"/></td></tr>
								</xsl:for-each>
								</table>
							</td>
						</tr>
					</xsl:for-each>
				</table>
				
				<table width="100%">
					<tr><td width="50%">
					<h2>Workflow Statistics</h2>
					<iframe src ="http://tyr12.cs.indiana.edu:6007/hasthi/GetWorkflowStaistics/48" width="100%" height="300px">
					  <p>Your browser does not support iframes.</p>
					</iframe>
					</td><td width="50%">
					<h2>Hasthi Statistics</h2>
					<iframe src ="http://tyr12.cs.indiana.edu:6007/hasthi/HasthiStats/" width="100%" height="300px">
					  <p>Your browser does not support iframes.</p>
					</iframe>
					</td></tr>
				</table>
				<table width="100%">
					<tr><td width="100%">
					<h2>Management Actions</h2>
					<iframe src ="http://tyr12.cs.indiana.edu:6007/hasthi/Actions/" width="100%" height="150px">
					  <p>Your browser does not support iframes.</p>
					</iframe>
					</td></tr><tr><td width="100%">
					<h2>Hasthi Logs</h2>
					<iframe src ="http://tyr12.cs.indiana.edu:6007/hasthi/Logs/" width="100%" height="150px">
					  <p>Your browser does not support iframes.</p>
					</iframe>
					</td></tr>
				</table>
				
			</body>
		</html>
	</xsl:template>
</xsl:stylesheet>